# 字符串
# s = input("请输入字符")
# if len(s):
#     print("第一个字符是：", s[0])
# if len(s):
#     print("最后一个字符是：", s[-1])
# if len(s) % 2 == 1:
#     m = len(s) // 2
#     m = int(m)
#     print("中间字符为：", s[m])
# s = "abcdef"
# print(s[:2:])
# hetong_format = "k---%s-l---%s--o---%s"
# hetong1 = hetong_format % ("hang", 110, 100)
# # print(hetong1)
# s_name = "姓名：{} ，年龄：{}"
# print(s_name.format("吕康",33))
# i = int(input("请输入行数："))
# k = 1
# while k <= i:
#     print("kangge" , "第" ,k , "行",  end='')
#     k = k + 1
#
# else :
#     print()
#     print("jingjie")
# n = 0
# i = 1
# while i <= 100:
#     n=n+i
#     i=i+1
# print(n)
# x = 1
# while x <= 20:
#     print("%2d" %x ,end=' ')
#     if x % 5 == 0:
#         print()
#     x = x + i
# i = int(input("请输入数字"))
# n = 1
# while n<=i:
#     x = 1
#     while x <= i:
#         print(x, end=" ")
#         x += 1
#     print()
#     n += 1

# number = 0
# allage=0
# while True :
#     age = int(input("输入年龄"))
#     if age <=0:
#         break
#     number += 1
#     allage=allage+age
# print(number)
# print(allage/number)
# for 循环

# s = "ABCDE"
# for mark in s :
#     print("循环遍历：", mark)
# else:
#     print("循环结束")
# s = input("请输入英文文字")
# count = 0
# for blank in s:
#     if blank == " ":
#         count += 1
# print("空格个数是：", count)
# print("kange", s.count(" "))
# # 用while循环
# index = 0
# while index <len(s):
#     blank = s[index]
#     if blank == " ":
#         count += 1
#     index +=1
# print("空格是", count)
# range 学习
# number = range(1, 21)
#
# for _ in range(10):
#     for s in number:
#         print(s, end=" ")
#     print()
# continue 循环学习
# for x in range(5):
#     if x % 2 == 0:
#         continue
#     print(x)
# user = input("请输入用户名：")
# password = input("请输入密码：")
# for _ in range(2):
#     if user == "root" and password == "123456":
#         print("登录成功")
#     else:
#         user = input("请输入用户名：")
#         password = input("请输入密码：")
# else:
#     print("登录失败，明天再来")

# 练习
# for time in range(3):
#     user = input("请输入用户名：")
#
#     if user != 'root':
#         print('用户名错误')
#         continue
#     password = input("请输入密码：")
#     if password != '123456':
#         print('密码错误')
#         continue
#     else:
#         print('登录成功')
#         break
# else:
#     print('登录3次失败，明天再来')

# 练习day5 2023.9.26 一大节8小节 列表list（） 增删改查

#增加： l.append()增加到最后   l.insert(i,x)  增加到下标为i的前面  l.extend(t)  增加一个列表在后面 也可以用 s+=t
#删除： l.remove()删除指定位置第一个      l.pop() 默认删除最后一位或者删除指定下标  l.clear()清空列表  del也可以
#
# l1 = [23,35,56,13,15,16]
# del l1[::2]
# print(l1)

#修改

# l2 = [1,2.11,3,4]
#
# l2[1] = 823
# l2.sort(reverse=True)
# print(l2)

# 列表的集中属性用法， reverse（）倒序； s.copy()复制拷贝，直接赋值是绑定的同一个数值
#l1.sort()  从小到大排序sort

#字符分割， str.split() 合并字符串 '-'.join()
# curdate = '2023/09/27'
# mylist = curdate.split('/')
# print(mylist)
# newlist = '-'.join(mylist)
# print(newlist)

#列表推导式（解析式）
# result =[]   #先创建一个空列表
# for x in range(1,11):
#     result.append(x ** 2)
# print(result)
# result2 = [x ** 2 for x in range(1,11)] #推导式写法
# print(result2)

# s1 = 'ABC'
# s2 = '123'
# sult = []
# for x in s1 :
#     for y in s2 :
#         sult.append(x+y)
# print(sult)
# sult2 = [x+y for x in s1 for y in s2]
# print(sult2)


# 练习 斐波那契数列
# sult = [0,1]
# while len(sult) <= 20 :
#     f = sult[-1]+sult[-2]
#     sult.append(f)
# print(sult)

#9.27  1.9 圣诞树练习

# s = '*'
# g = '$'
# case = int(input("请输入树的高度尺寸数字："))
# for case in range(case)
#     print(case-(case))

#乘法表练习
# for row in range(1,10):
#     for col in range(1,10):
#          if col > row:
#              break
#          print(f'{row}*{col}={row*col}',end=" ")
#     print()

# 字典 dict {}
#
# d1 = dict(name='吕康', sex='男')
# d2 = {'name':吕康', 'sex'='男'}
# print(d1)
#
# d3 = dict(a=1,b=2)
# for key in d3 :
#     print(key,d3[key])

# > 提示：
# >
# > 1. 将 . 等符号替换为空格
# > 2. 用 字符串的 .split() 方法 拆分单词
# > 3. 遍历所有的单词，用字典的键代表单词，用值代表单词出现的次数。进行统计。
# > 4. 遍历字典，给出结果

# # s = input('请输入')
# s = 'welcome to beijing.      I love beijing. I love you.'
# # > 1. 将 . 等符号替换为空格
# s2 = s.replace('.', ' ')
# # s2 = s2.replace('  ', ' ')
# # > 2. 用 字符串的 .split() 方法 拆分单词
# # words = s2.split(' ')
# words = s2.split()   # .split() 不给参数， 以n个连续的空白字符分割
# # > 3. 遍历所有的单词，用字典的键代表单词，用值代表单词出现的次数。进行统计。
# stat_dict = {}  # 创建一个空的字典用来统计
# for aword in words:
#     if aword in stat_dict:  # aword已经出现过
#         stat_dict[aword] += 1
#     else:
#         stat_dict[aword] = 1  # 第一次出现
# # > 4. 遍历字典，给出结果
# for key in stat_dict:
#     print(f'{key} 出现了 {stat_dict[key]} 次！')


# # tuple 元组
# t1 = () #创建空元组
# t2 = (100,) #必须加一个逗号，才是一个数据的元组t2 = 100,
#
# t3 = (1,2,3)
# t4 = 5, 6, 7, 8
# print(t3)
# print(t4)
# #type(x),   返回x的类型
#
# print(type(100))
#
# #set 集合 frozenset
# s1 = set()
# s2 = set(range(3))
# s3 = {100, 200, 300,}
# # &交集 |并集
#
# l1 = {8, 45, 88, 62,57, 89,}
#
# #l1.add(99)
# l1.pop()
# print(l1)

